import CodingType from './CodingType.js';

export default class CodingMethodParameter {

    annotation = '';
    /**
     * @type {CodingType}
     */
    type = null;
    name = '';

    constructor(type, name) {
        if (!(type instanceof CodingType)) {
            throw new Error('The "type" must be instance of CodingType');
        }
        this.type = type;
        this.name = name;
    }

    toString() {
        let s = '';
        if (this.annotation) {
            let annotation = this.annotation;
            if (!annotation.startsWith('@')) {
                annotation = '@' + annotation;
            }
            s += `${annotation} `;
        }
        s += this.type + ' ' + this.name;
        return s;
    }

}
